package org.hentor.config.redis;


import cn.hutool.core.util.ObjectUtil;
import org.hentor.common.util.SpringContextHolder;
import org.hentor.config.redis.listener.HentorRedisListener;
import org.springframework.stereotype.Component;

@Component
public class RedisReceiver {
    public void onMessage(BaseMap params) {
        Object handlerName = params.get("handlerName");
        HentorRedisListener messageListener = (HentorRedisListener) SpringContextHolder.getHandler(handlerName.toString(), HentorRedisListener.class);
        if (ObjectUtil.isNotEmpty(messageListener)) {
            messageListener.onMessage(params);
        }

    }

    public RedisReceiver() {
    }

    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof RedisReceiver)) {
            return false;
        } else {
            RedisReceiver other = (RedisReceiver)o;
            return other.canEqual(this);
        }
    }

    protected boolean canEqual(final Object other) {
        return other instanceof RedisReceiver;
    }

    public int hashCode() {
        return 1;
    }

    public String toString() {
        return "RedisReceiver()";
    }
}
